#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int jewelleryValue(vector<vector<int>>& frame) {
        int price = 0;
        int n = frame.size(), m = frame[0].size();
        vector<vector<int>>dp(n, vector<int>(m));
        dp[0][0] = frame[0][0];
        price = dp[0][0];
        for (int i = 1; i < m; i++)
        {
            dp[0][i] += dp[0][i - 1] + frame[0][i];
            price = max(price, dp[0][i]);
        }
        for (int j = 1; j < n; j++)
        {
            dp[j][0] += dp[j - 1][0] + frame[j][0];
            price = max(price, dp[j][0]);
        }
        for (int i = 1; i < n; i++)
        {
            for (int j = 1; j < m; j++)
            {
                int high = max(dp[i - 1][j], dp[i][j - 1]);
                dp[i][j] = high + frame[i][j];
                price = max(dp[i][j], price);
            }
        }
        return price;

    }
};